package com.cn.qgx428.lazydiary.ui.fragment


import android.os.Bundle
import android.support.v4.app.Fragment
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

/**
 * Created by QinX on 2017/12/14.
 */
abstract class BaseFragment :  Fragment(){

    var mView : View? = null

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        if(mView == null){
            mView = inflater!!.inflate(getLayoutId(),container,false)
        }
      //  return mView ?: inflater!!.inflate(getLayoutId(),container,false)
        return mView!!
    }

    override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    abstract protected fun getLayoutId(): Int

    abstract protected fun initView()

    public fun log(msg : String) = Log.d(javaClass.name, msg)
}